﻿using System;
using System.Collections.Generic;
using System.Web;
using PayRoller.Code;
using System.Web.SessionState;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using HySoft.Cash.Business;
using HySoft.Cash.Structure;
using System.Configuration;
using System.Web.Profile;
using System.Data;
using HySoft.Cash.BaseClass;
using System.Data.SqlClient;
using HySoft.Cash;

namespace PayRoller.Manage.Invoices
{
    public class InvoiceDetail : ParentPage, IRequiresSessionState
    {
        //// Fields
        //public DataTable dtEmpList = new DataTable();
        //public double fAnnualRate;
        //public double fAvaBalance;
        //public double fClosingBalance;
        //public double fCreditLimit;
        //public double fDailyRate;
        //public double fInterestCharges;
        //protected HtmlForm form1;
        //public double fPenalty;
        //public double fS1;
        //public double fSumAmount;
        //public double fSumFinanceCost;
        //public double fSumNetPay;
        //public double fTotalDue;
        //protected HtmlHead Head1;
        //public int iEmialDueDate;
        //public int iInvoiceDueDate;
        //public int OrgSid;
        //public string sContactPerson = "";
        //public string sInvoiceAmount = "";
        //public string sInvoiceDate = "";
        //public string sInvoiceSid = "";
        //public string sInvoiceToDate = "";
        //public string sOrgName = "";
        //public string sPaymentDate = "";
        //public string sPostalAddress = "";

        //// Methods
        //public double GetClosingBalance(int OrgSid)
        //{
        //    SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@OrgSid", OrgSid) };
        //    DataTable table = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["SQLConnString"], CommandType.StoredProcedure, "GetClosingBalanceByOrgSid", commandParameters).Tables[0];
        //    if (table.Rows.Count > 0)
        //    {
        //        return Convert.ToDouble(table.Rows[0][0]);
        //    }
        //    return 0.0;
        //}

        //public double GetEmpAmount(int EmpSid)
        //{
        //    double num = 0.0;
        //    double num2 = 0.0;
        //    TemppaymentBN tbn = new TemppaymentBN(this.Page);
        //    tbn.QueryEmpSid(EmpSid);
        //    DataTable list = tbn.GetList();
        //    for (int i = 0; i < list.Rows.Count; i++)
        //    {
        //        num2 = Convert.ToDouble(list.Rows[i]["PaymentAmount"]);
        //        num += num2;
        //    }
        //    tbn.Close();
        //    tbn.Dispose();
        //    return num;
        //}

        //public DataTable GetEmpList(int OrgSid)
        //{
        //    SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@OrgSid", OrgSid), new SqlParameter("@PaymentDate", this.sPaymentDate) };
        //    return SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["SQLConnString"], CommandType.StoredProcedure, "GetEmpInvoiceByOrg", commandParameters).Tables[0];
        //}

        //public void GetInvoiceInfo(int Sid)
        //{
        //    TinvoicelistBN tbn = new TinvoicelistBN(this.Page);
        //    TinvoicelistDT tdt = tbn.Get(Sid);
        //    this.sInvoiceDate = tdt.InvoiceDate.ToString(AppSettings.DateFormatAU);
        //    this.sPaymentDate = tdt.PaymentDate.ToString(AppSettings.SystemCulture);
        //    this.sInvoiceAmount = tdt.InvoiceAmount.ToString();
        //    this.fPenalty = Convert.ToDouble(tdt.Penalty);
        //    this.fInterestCharges = Convert.ToDouble(tdt.LateInterestCharges);
        //    this.sInvoiceToDate = Convert.ToDateTime(tdt.InvoiceDate).AddDays(7.0).ToShortDateString();
        //    tbn.Close();
        //    tbn.Dispose();
        //}

        //public string GetInvoiceSidByGuid(string Guid)
        //{
        //    TinvoicelistBN tbn = new TinvoicelistBN(this.Page);
        //    tbn.QueryGuid(Guid);
        //    DataTable list = tbn.GetList();
        //    tbn.Close();
        //    tbn.Dispose();
        //    if (list.Rows.Count > 0)
        //    {
        //        return list.Rows[0]["Sid"].ToString();
        //    }
        //    return "";
        //}

        //public void GetOrgInfo(int OrgSid)
        //{
        //    TorginfoBN obn = new TorginfoBN(this.Page);
        //    TorginfoDT odt = obn.Get(OrgSid);
        //    this.sOrgName = odt.OrgName;
        //    this.sContactPerson = odt.ContactPerson;
        //    this.sPostalAddress = odt.PostalAddress;
        //    this.fCreditLimit = Convert.ToDouble(odt.CreditLimit);
        //    obn.Close();
        //    obn.Dispose();
        //}

        //public double GetSumFinanceCost(DataTable dt)
        //{
        //    double num = 0.0;
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        double num4 = ((Convert.ToDouble(dt.Rows[i]["Amount"]) * 0.01) * this.fDailyRate) * this.iInvoiceDueDate;
        //        num += num4;
        //    }
        //    return num;
        //}

        //public string GetSysOptionValue(int Sid)
        //{
        //    TsysoptionBN nbn = new TsysoptionBN(this.Page);
        //    TsysoptionDT ndt = nbn.Get(Sid);
        //    nbn.Close();
        //    nbn.Dispose();
        //    if (ndt != null)
        //    {
        //        return ndt.OptionValue;
        //    }
        //    return "";
        //}

        //protected void Page_Load(object sender, EventArgs e)
        //{
        //    if (((base.Request["OrgSid"] != null) && (base.Request["Guid"] != null)) && (base.Request["Guid"].ToString() != ""))
        //    {
        //        this.iInvoiceDueDate = Convert.ToInt32(this.GetSysOptionValue(2));
        //        this.iEmialDueDate = Convert.ToInt32(this.GetSysOptionValue(3));
        //        this.fAnnualRate = Convert.ToDouble(this.GetSysOptionValue(4));
        //        this.fDailyRate = Convert.ToDouble(this.GetSysOptionValue(5));
        //        this.sInvoiceSid = this.GetInvoiceSidByGuid(base.Request["Guid"].ToString());
        //        this.OrgSid = Convert.ToInt32(base.Request["OrgSid"]);
        //        this.GetOrgInfo(this.OrgSid);
        //        this.fClosingBalance = this.GetClosingBalance(this.OrgSid);
        //        this.fAvaBalance = this.fCreditLimit - this.fClosingBalance;
        //        this.GetInvoiceInfo(Convert.ToInt32(this.sInvoiceSid));
        //        this.dtEmpList = this.GetEmpList(this.OrgSid);
        //        this.fSumFinanceCost = this.GetSumFinanceCost(this.dtEmpList);
        //        this.fTotalDue = ((this.fClosingBalance + this.fSumFinanceCost) + this.fPenalty) + this.fInterestCharges;
        //    }
        //}

        // Properties
        protected HttpApplication ApplicationInstance
        {
            get
            {
                return this.Context.ApplicationInstance;
            }
        }

        protected DefaultProfile Profile
        {
            get
            {
                return (DefaultProfile)this.Context.Profile;
            }
        }
    }

}

